import { filterZero } from '../filters/filterZero';
import { Notice, Message } from 'iview';
/* 空值提示： desc提示内容;type提示的类型;title提示的标题 */
const noticeTips = (desc, type = 'warning', title = '提示') => {
    return Notice[type]({ title: title, desc: desc });
};
const messageTips = (desc, type = 'warning') => {
    return Message[type](desc);
};
const formatDate = (d) => {
    let date = new Date(d);
    return date.getFullYear() + '-' + filterZero((date.getMonth() + 1)) + '-' + filterZero(date.getDate()) + ' ' + filterZero(date.getHours()) + ':' + filterZero(date.getMinutes()) + ':' + filterZero(date.getSeconds());
};
const getToMonth = () => {
    let date = new Date();
    return date.getFullYear() + '-' + filterZero((date.getMonth() + 1));
};
const getToDay = () => {
    // 精确到天
    let d = new Date();
    let year = d.getFullYear();
    let month = d.getMonth() + 1;
    let day = d.getDate();
    let date = year + '-' + filterZero(month) + '-' + filterZero(day);
    return date;
};

const getToTime = () => {
    // 精确到秒
    let d = new Date();
    let year = d.getFullYear();
    let month = d.getMonth() + 1;
    let day = d.getDate();
    let hour = d.getHours();
    let minute = d.getMinutes();
    let second = d.getSeconds();
    let date = year + '-' + filterZero(month) + '-' + filterZero(day) + ' ' + filterZero(hour) + ':' + filterZero(minute) + ':' + filterZero(second);
    return date;
};
const clearSpace = (str) => {
    return str.replace(/(^\s*)|(\s*$)/g, '');
};
const operationTips = (type) => {
    switch (type) {
        case 'saveTips':
            Notice.success({ title: '提示', desc: '保存成功!' });
            break;
        case 'submitTips':
            Notice.success({ title: '提示', desc: '提交成功!' });
            break;
        case 'cancelTips':
            Notice.success({ title: '提示', desc: '撤销提交成功!' });
            break;
        case 'auditTips':
            Notice.success({ title: '提示', desc: '审核成功!' });
            break;
        case 'unAuditTips':
            Notice.success({ title: '提示', desc: '撤销审核成功!' });
            break;
        case 'closeTips':
            Notice.success({ title: '提示', desc: '关闭单据成功!' });
            break;
        case 'unCloseTips':
            Notice.success({ title: '提示', desc: '撤销关闭成功!' });
            break;
        case 'deleteTips':
            Notice.success({ title: '提示', desc: '删除成功!' });
            break;
        case 'disableTips':
            Notice.success({ title: '提示', desc: '禁用成功!' });
            break;
        case 'enableTips':
            Notice.success({ title: '提示', desc: '启用成功!' });
            break;
        case 'quoteTips':
            Modal.warning({ title: '提示', content: '单据已被引用，不能进行撤销审核!' });
            break;
        case 'unCheckTips':
            Notice.warning({ title: '提示', desc: '请选择操作对象!' });
            break;
        case 'unCompleteTips':
            Message.warning('请填写完整!'); // 表单验证的提示
            break;
        default:
            Notice.success({ title: '提示', desc: '操作成功!' });
    };
};

export { noticeTips, messageTips, formatDate, getToMonth, getToDay, getToTime, clearSpace, operationTips };
